package starter.pageobjects.orangehrmlive;

import net.serenitybdd.core.pages.PageObject;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;

/**
 * @ClassName HeaderPage
 * @Date 2024/10/29 16:17 05
 * @Author Jack Chen
 * @Description serenity-cucumber-page-objects-starter-master
 * @Version 1.0
 */

public class TopbarPage extends PageObject {
    /**
     * topbar-header elements
     */
    public static final By PAGETITLE = By.cssSelector("div.oxd-topbar-header h6.oxd-text");
    public static final By UPGRADE = By.cssSelector("div.oxd-topbar-header .orangehrm-upgrade-container>a");
    public static final By USERDROPDOWN = By.cssSelector(".oxd-topbar .oxd-topbar-header-userarea>ul>li.oxd-userdropdown");
    public static final By ABOUT = By.cssSelector(".oxd-topbar .oxd-topbar-header-userarea>ul>li.oxd-userdropdown>ul>li:nth-child(1)>a");
    public static final By SUPPORT = By.cssSelector(".oxd-topbar .oxd-topbar-header-userarea>ul>li.oxd-userdropdown>ul>li:nth-child(2)>a");
    public static final By CHANGEPASSWORD = By.cssSelector(".oxd-topbar .oxd-topbar-header-userarea>ul>li.oxd-userdropdown>ul>li:nth-child(3)>a");
    public static final By LOGOUT = By.cssSelector(".oxd-topbar .oxd-topbar-header-userarea>ul>li.oxd-userdropdown>ul>li:nth-child(4)>a");
    public static final By USERPIC = By.cssSelector(".oxd-topbar .oxd-topbar-header-userarea>ul>li.oxd-userdropdown span img");
    public static final By USERNAME = By.cssSelector(".oxd-topbar .oxd-topbar-header-userarea>ul>li.oxd-userdropdown span p");

    /**
     * Topbar Menu elements
     * This is the common web elements for all the content pages to use
     */
    /* Admin top bar menus */
    public static final By Admin_UserManagement = By.xpath("//nav[@class='oxd-topbar-body-nav']/ul/li/span[contains(text(),'User Management')]");
    public static final By Admin_UserManagement_Users = By.xpath("");
    public static final By Admin_Job = By.xpath("//nav[@class='oxd-topbar-body-nav']/ul/li/span[contains(text(),'Job')]");
    public static final By Admin_Job_JobTitles = By.xpath("");
    public static final By Admin_Job_PayGrades = By.xpath("");
    public static final By Admin_Job_EmploymentStatus = By.xpath("");
    public static final By Admin_Job_JobCategories = By.xpath("");
    public static final By Admin_Job_WorkShifts = By.xpath("");
    public static final By Admin_Organization = By.xpath("//nav[@class='oxd-topbar-body-nav']/ul/li/span[contains(text(),'Organization')]");
    public static final By Admin_Organization_GeneralInformation = By.xpath("");
    public static final By Admin_Organization_Locations = By.xpath("");
    public static final By Admin_Organization_Structure = By.xpath("");
    public static final By Admin_Qualifications = By.xpath("//nav[@class='oxd-topbar-body-nav']/ul/li/span[contains(text(),'Qualifications')]");
    public static final By Admin_Qualifications_Skills = By.xpath("");
    public static final By Admin_Qualifications_Education = By.xpath("");
    public static final By Admin_Qualifications_Licenses = By.xpath("");
    public static final By Admin_Qualifications_Languages = By.xpath("");
    public static final By Admin_Qualifications_Memberships = By.xpath("");
    public static final By Admin_Nationalities = By.xpath("//nav[@class='oxd-topbar-body-nav']/ul/li/a[contains(text(),'Nationalities')]");
    public static final By Admin_CorporateBranding = By.xpath("//nav[@class='oxd-topbar-body-nav']/ul/li/a[contains(text(),'Corporate Branding')]");
    public static final By Admin_Configuration = By.xpath("//nav[@class='oxd-topbar-body-nav']/ul/li/span[contains(text(),'Configuration ')]");
    public static final By Admin_Configuration_EmailConfiguration = By.xpath("");
    public static final By Admin_Configuration_EmailSubscriptions = By.xpath("");
    public static final By Admin_Configuration_Localization = By.xpath("");
    public static final By Admin_Configuration_LanguagePackages = By.xpath("");
    public static final By Admin_Configuration_Modules = By.xpath("");
    public static final By Admin_Configuration_SocialMediaAuthentication = By.xpath("");
    public static final By Admin_Configuration_RegisterOAuthClient = By.xpath("");
    public static final By Admin_Configuration_LDAPConfiguration = By.xpath("");
    /* PIM top bar menus */
    public static final By PIM_Configuration = By.xpath("");
    public static final By PIM_Configuration_OptionalFields = By.xpath("");
    public static final By PIM_Configuration_CustomFields = By.xpath("");
    public static final By PIM_Configuration_DataImport = By.xpath("");
    public static final By PIM_Configuration_ReportingMethods = By.xpath("");
    public static final By PIM_Configuration_TerminationReasons = By.xpath("");
    public static final By PIM_EmployerList = By.xpath("");
    public static final By PIM_AddEmployee = By.xpath("");
    public static final By PIM_Reports = By.xpath("");
    /* Leave top bar menus */
    public static final By Leave_Apply = By.xpath("");
    public static final By Leave_MyLeave = By.xpath("");
    public static final By Leave_Entitlements = By.xpath("");
    public static final By Leave_Entitlements_AddEntitlements = By.xpath("");
    public static final By Leave_Entitlements_EmployeeEntitlements = By.xpath("");
    public static final By Leave_Entitlements_MyEntitlements = By.xpath("");
    public static final By Leave_Reports = By.xpath("");
    public static final By Leave_Reports_LeaveEntitlementsAndUsageReport = By.xpath("");
    public static final By Leave_Reports_MyLeaveEntitlementsAndUsageReport = By.xpath("");
    public static final By Leave_Configure = By.xpath("");
    public static final By Leave_Configure_LeavePeriod = By.xpath("");
    public static final By Leave_Configure_LeaveTypes = By.xpath("");
    public static final By Leave_Configure_WorkWeek = By.xpath("");
    public static final By Leave_Configure_Holidays = By.xpath("");
    public static final By Leave_LeaveList = By.xpath("");
    public static final By Leave_AssignLeave = By.xpath("");
    /* Time top bar menus */
    public static final By Time_Timesheets = By.xpath("");
    public static final By Time_Timesheets_MyTimesheets = By.xpath("");
    public static final By Time_Timesheets_EmployeeTimesheets = By.xpath("");
    public static final By Time_Attendance = By.xpath("");
    public static final By Time_Attendance_MyRecords = By.xpath("");
    public static final By Time_Attendance_PunchInOut = By.xpath("");
    public static final By Time_Attendance_EmployeeRecords = By.xpath("");
    public static final By Time_Attendance_Configuration = By.xpath("");
    public static final By Time_Reports = By.xpath("");
    public static final By Time_Reports_ProjectReports = By.xpath("");
    public static final By Time_Reports_EmployeeReports = By.xpath("");
    public static final By Time_Reports_AttendanceSummary = By.xpath("");
    public static final By Time_projectInfo = By.xpath("");
    public static final By Time_projectInfo_Customers = By.xpath("");
    public static final By Time_projectInfo_Projects = By.xpath("");
    /* Recruitment top bar menus */
    public static final By Recruitment_Candidates = By.xpath("");
    public static final By Recruitment_Vacancies = By.xpath("");
    /* My Info top bar menus, Nothing */
    /* Performance top bar menus */
    public static final By Performance_Configure = By.xpath("");
    public static final By Performance_Configure_KPIs = By.xpath("");
    public static final By Performance_Configure_Trackers = By.xpath("");
    public static final By Performance_ManageReviews = By.xpath("");
    public static final By Performance_ManageReviews_ManageReviews = By.xpath("");
    public static final By Performance_ManageReviews_MyReviews = By.xpath("");
    public static final By Performance_ManageReviews_EmployeeReviews = By.xpath("");
    public static final By Performance_MyTrackers = By.xpath("");
    public static final By Performance_EmployeeTrackers = By.xpath("");
    /* Dashboard top bar menus, nothing
    Directory top bar menus, nothing **/
    /* Maintenance top bar menus */
    public static final By Maintenance_PurgeRecords = By.xpath("");
    public static final By Maintenance_PurgeRecords_EmployeeRecords = By.xpath("");
    public static final By Maintenance_PurgeRecords_CandidateRecords = By.xpath("");
    public static final By Maintenance_AccessRecords = By.xpath("");
    /* Claim top bar menus */
    public static final By Claim_Configuration = By.xpath("");
    public static final By Claim_Configuration_Events = By.xpath("");
    public static final By Claim_Configuration_ExpenseTypes = By.xpath("");
    public static final By Claim_SubmitClaim = By.xpath("");
    public static final By Claim_MyClaims = By.xpath("");
    public static final By Claim_EmployeeClaims = By.xpath("");
    public static final By Claim_AssignClaim = By.xpath("");
    /* Buzz top bar menus, nothing */

    public String getCurrentPageTitle() {
        Wait<WebDriver> wait = new WebDriverWait(getDriver(), Duration.ofSeconds(5));
        WebElement pageTitle = wait.until(ExpectedConditions.visibilityOfElementLocated(PAGETITLE));
        //return $(PAGETITLE).getAttribute("src");
        return pageTitle.getText();
    }

    public String getUserPicture() {
        return $(USERPIC).getText();
    }

    public String getCurrentUsername() {
        return $(USERNAME).getText();
    }

    public void clickUpgrade() {
        $(UPGRADE).click();
    }

    public void clickUserDowndown() {
        $(USERDROPDOWN).click();
    }

    public void clickAbout() {
        $(ABOUT).click();
    }

    public void clickSupport() {
        $(SUPPORT).click();
    }

    public void clickChangePassword() {
        $(CHANGEPASSWORD).click();
    }

    public void clickLogout() {
        $(LOGOUT).click();
    }

    public boolean checkPageDisplayed(String pageName) {
        String title = getCurrentPageTitle();
        return title.contains(pageName);
    }
}
